#include <iostream>
#include <exception>

using namespace std;

double division(int a, int b){
    return a / b;
}

class MyException : public exception{
public:
    const char* what() const throw(){
        return "C++ exception";
    }
};

int main(){
    int x = 50;
    int y = 0;
    double z = 0.0;
    
    try{
        z = division(x, y);
        cout << z << endl;
    }
    catch(exception& e){
        cout << e.what() << endl;
    }

    try{
        throw MyException();
    }
    catch(MyException& e){
        cout << "MyException caught" << endl;
        cout << e.what() << endl;
    }
    return 0;
}